<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	    window.onload = function (){
	    	var oBtn1 = document.getElementById('btn1');
	    	var oBtn2 = document.getElementById('btn2');
	    	var time = '';


	    	oBtn1.onclick = function (){
	    		function start(){
	    		    alert('a');
	    	    }

	    	    time = setInterval(start,1000);
	    	}

	    	oBtn2.onclick = function (){
	    		clearInterval(time);
	    	}
	    }

	</script>
</head>
<body>

    <input id="btn1" type="button" value="开启" />
    <input id="btn2" type="button" value="关闭" />
	
</body>
</html>